﻿using AnQinFrameWorkAPI.Entity.Develop.DTO.DevelopProjectDemand;
using AnQinFrameWorkAPI.Entity.Develop.View.DevelopProjectDemand;
using AnQinFrameWorkAPI.Service.Develop;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Develop;

/// <summary>
///     开发管理项目需求
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Develop")]
public class DevelopProjectDemandController : ControllerBase
{
    //业务服务接口
    private readonly DevelopProjectDemandService _developProjectDemandService;

    //构造注入
    public DevelopProjectDemandController(DevelopProjectDemandService developProjectDemandService)
    {
        _developProjectDemandService = developProjectDemandService;
    }

    /// <summary>
    ///     获取开发管理项目需求列表
    /// </summary>
    /// <param name="developProjectDemandSearchDTO"></param>
    [ProducesResponseType(typeof(DevelopProjectDemandView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetDevelopProjectDemandList(
        [FromQuery] DevelopProjectDemandSearchDTO developProjectDemandSearchDTO)
    {
        var response = await _developProjectDemandService.GetProjectDemandList(developProjectDemandSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增开发管理项目需求
    /// </summary>
    /// <param name="developProjectDemandAddDTO"></param>
    [HttpPost]
    public async Task<IActionResult> AddDevelopProjectDemand(
        [FromBody] DevelopProjectDemandAddDTO developProjectDemandAddDTO)
    {
        var response = await _developProjectDemandService.AddDevelopProjectDemand(developProjectDemandAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新开发管理项目需求
    /// </summary>
    /// <param name="developProjectDemandUpdareDTO"></param>
    [HttpPut]
    public async Task<IActionResult> PutDevelopProjectDemand(
        [FromBody] DevelopProjectDemandUpdareDTO developProjectDemandUpdareDTO)
    {
        var response = await _developProjectDemandService.PutDevelopProjectDemand(developProjectDemandUpdareDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除开发管理项目需求
    /// </summary>
    /// <param name="deleteDTO"></param>
    [HttpDelete]
    public async Task<IActionResult> DeleteDevelopProjectDemand([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _developProjectDemandService.DeleteDevelopProjectDemand(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     批量删除开发管理项目需求
    /// </summary>
    /// <param name="idArrayDTO"></param>
    [HttpPost("DeleteMulti")]
    public async Task<IActionResult> DeleteArrayDevelopProjectDemand([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _developProjectDemandService.DeleteArrayDevelopProjectDemand(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}